package com.iot.ic.controller;

import java.util.Date;
import java.util.Map;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.iot.ic.base.BaseController;
import com.iot.ic.common.Response;
import com.iot.ic.common.ReturnCode;
import com.iot.ic.model.AppVersion;
import com.iot.ic.model.ManualIntervention;
import com.iot.ic.model.MatchPause;
import com.iot.ic.model.TeamLocation;
import com.iot.ic.service.AppVersionService;
import com.iot.ic.service.MatchPauseService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(description = "app版本更新相关接口")
@RestController
public class MatchPauseController extends BaseController {
	
	@Autowired
	private MatchPauseService matchPauseService;
	
	/**
	 * 获取最新版本的app
	 * @param appVersion
	 * @return
	 */
	@ApiOperation(value="开始暂停信息", notes="")
	@ResponseBody
	@RequestMapping(value="/matchPause/start",method=RequestMethod.POST)
	public Response<Map<String, Object>> addMatchPause(@Valid@RequestBody MatchPause matchPause){
		Response response=new Response();
		matchPause.setStartTime(new Date());
        int result=matchPauseService.startMatchPause(matchPause);
        if (result > 0) {
			response.setInfos(ReturnCode.No_Err);
			response.setResult(result);
		} else {
			response.setInfos(ReturnCode.Err_SaveLocationFailor);
		}
		return response;
	}
	
	
	/**
	 * 结束人工干预
	 * @param RefereeInfo
	 * @return
	 */
	@ApiOperation(value="结束人工干预", notes="")
	@RequestMapping(value="/matchPause/end/{matchPauseId}", method=RequestMethod.PUT)
	public Response endManualIntervention(
			@PathVariable("matchPauseId") int matchPauseId){
		Response response = new Response();
		MatchPause matchPause = new MatchPause();
		matchPause.setMatchPauseId(matchPauseId);
		matchPause.setEndTime(new Date());
		int result = matchPauseService.endMatchPause(matchPause);
		response.setResult(result);
		return response;
	}
	

}
